Hot answers tagged google-maps
3
Well, this is kind of easy..
The google-map API needs a format like Your Street 123, 54321 Your City
Assuming you have your data like this:
<div id="street">Your Street 123</div>
<div id="zip">54321</div>
<div id="city">Your City</div>
Assuming you are using jQuery:
(function($){
$.fn.create_gmap_address = ...
3
You should avoid creating more tables. Just do it if you really have a good reason to. Note that wp_postmeta can store practically any kind of data, and simply using the get_post_meta function can do all the job in most cases.
But if you must use another table, and taking it generally, then you're looking for the save_post and delete_post hooks.
...
3
Mappress allows for custom markers, but you need to pay for the pro version.
http://wordpress.org/extend/plugins/mappress-google-maps-for-wordpress/
Google Map Shortcode also supports custom markers in a shortcode
http://wordpress.org/extend/plugins/google-map-shortcode/
Getting custom overlays on Google maps is actually pretty easy, you can read the docs ...
3
Wierd, just re-read your comment and looks like your shortcode is working when you call it that early - if the map-canvas div is showing up. here's the code I tested, also added jquery as a dependency for your custom script & changed some css on you div...
function lax_google_map_init() {
wp_enqueue_script('google-maps', ...
2
These errors come from CSS rules from your WordPress theme that are also applied to elements on the map. For example, on your page, I was able to fix the popup by disabling the #content table and #content tr th rules which add extra margins. In a test setup I even got gray gaps between the tiles because of .entry-content img { max-width: 97.5% } in Twenty ...
2
You could use this plugin, although it may only be compatible to 3.2.1. And this plugin may help you out, although it seems a little complicated to implement a map for all the posts.
You could also use a custom field for lat/long on each post, and then create markers using wpdb calls, grabbing the post_meta data, and using the Google Maps API to place the ...
2
I think GeoMashup is the go-to plugin for something like this. http://wordpress.org/extend/plugins/geo-mashup/
I've used it for a similar site with great results. There's a lot to dig into, it's very flexible, but you'll definitely be able to get what you want.
2
Use the offset argument, and only get 1 result:
global $my_page_offset;
if(!isset($my_page_offset))
$my_page_offset = 0;
$pages = get_pages(array(
'child_of' => $post->ID,
'sort_column' => 'menu_order',
'offset' => $my_page_offset,
'number' => 1,
));
$my_page_offset++;
...
I'm assuming here that you don't have ...
2
This is a simple mathimatical problem.
You will indeed need access to both your longitude and latitude, so save it in a metafield.
than you will have to query your posts like this as a sql query.
Haven't got a chance to test it. and or pour it into wordpress.
Don't have access to my test env now.
But I guess you could do it yourself :) if not I'll do it ...
2
To connect your meta fields with the "Geo Data Store"-Plugin, you simply take the name of the meta key/field and map it with the filter to the plugin.
add_filter( 'sc_geodatastore_meta_keys', 'wpse82502_lat_lng_metakey_mapping' );
function wpse82502_lat_lng_metakey_mapping( $keys )
{
$keys[] = "your_meta_key_field_name";
return $keys;
}
To get the ...
1
You have quite a bit of markup for that shortcode. Trying to pass all of that as a shortcode is going to be trouble.
I pulled it apart to look at it.
id="map"
z="11"
w="100%"
h="300"
scrollwheel="false"
maptype="ROADMAP"
address="Southampton, United Kingdom"
marker="true"
...
1
Probably safest to put HTML content in as the "content" of an enclosing shortcode, not one of the "attributes":
[my_gmaps ...] HTML here [/my_gmaps]
Then access that block as the second parameter to the shortcode function:
function my_shortcode($attrs, $content) {}
1
This isn't a complete answer, but a couple of bits of advice -
Don't geocode the addresses on front-end requests, it's a waste of cycles. An address only needs to be geocoded once, then you can store the lat/lon data with your post meta. Use a save_post hook to do the geocoding when the post is saved on the back-end.
You can geocode addresses with php like ...
1
@Richard, it's hard to answer this in detail with this little details.
Do you need to pinpoint a single house?
Will you use an address or will you use latitude and longitude?
My suggestion would be to take a look at this excellent Google Maps Plugin for jQuery. jQuery is part of any WordPress installation, so you wouldn't need to install anything else. ...
1
The only way to get multiple markers on a map is to use the Google Maps API.
https://developers.google.com/maps/documentation/javascript/tutorial.
The way you are referencing through an iframe only allows one marker(one location).
1
For create the links to your child sites use this
function elenco_sotto_siti(){
global $wpdb;
$blogs = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->blogs WHERE public='1' AND archived='0' AND mature='0' AND spam='0' AND deleted='0' ORDER BY blog_id "),ARRAY_A );
return $blogs;
}
For question 2 and 3, i use the option ...
1
Mapsmarker looks pretty robust. On their feature list page they state that you can organize your markers in layers, so maybe that work for categories. I have not used it.
I have used Mappress which allows you to add custom markers and you can create different maps on different pages if you want to categorize them like that.
1
There are a lot of pieces to this puzzle.
You need to be able to convert the postcodes into a numerical data format so you can query the pages/posts with "is greater than [current location minus 5 miles] and less than [current location plus 5 miles". In two dimensions. This means storing the latitude and longitude with the page. You can automate this, so ...
1
By default, PHP is stripped out of the posts content. You can use this plugin to aleivate this:
http://wordpress.org/extend/plugins/exec-php/
This will give you a quick, easy fix to be able to do it the way you are trying to. I would suggest reading http://codex.wordpress.org/Custom_Fields for the more proper way to do this though.
1
Dean, your best bet is to do it through JS on the front end.
I use the following function to covert the postcode to a Lat and Lng:
function codeAddress(address){
geocoder.geocode({
'address': address
}, function(results, status){
if(status == google.maps.GeocoderStatus.OK){
map.setCenter(results[0].geometry.location);
...
1
Take a look at this I did for a client:
http://lpoc.co.uk/properties-for-sale/
A user can click the map and choose where to search. When a user clicks it updates a couple of hidden fields. Feel free to look at the source code to see how its done. If you want a more in depth description of the google maps api and javascript then this question would be ...
1
if u think that is the problem simply do:
$csf_map_output .= '<script>
jQuery(document).ready(function(){
var csf_map_params = ' . json_encode( $atts ) . ';
csf_map_maker_js( csf_map_params );
});
</script>';
I don't see any scope issues with the above code.
1
After some more Googling...
New single.php looks like this:
<?php
get_header();
global $wp_query;
if ( ! isset( $wp_query->query_vars['map'] ) )
{
if (have_posts()) :
while (have_posts()) :
the_post();
the_title();
the_content();
endwhile;
endif;
?>
<p><a ...
1
From quick test snippet you provided does embed map seemingly correctly. There is nothing on that map, because marker points to the middle of nowhere, you can see some road if you drag around.
Are you inserting this in body of page? In HTML mode?
It is good practice to make use of wp_enqueue_script(), when dealing with scripts in WordPress. However your ...
1
Unfortunately there is no easy fix for this, I tried this myself a while ago, and ended up not using any tabs for map rendering since it was the only reliable option.
I had some success with messing about with CSS but all browsers (and mobile) reacted differently.
The reason is Google maps computes it's values on page load, there are some hacky solutions ...
Only top voted, non community-wiki answers of a minimum length are eligible