google-maps,google-maps-api-3,filter,markerclusterer , Recalculate markercluster and downloadUrl


Recalculate markercluster and downloadUrl

Question:

Tag: google-maps,google-maps-api-3,filter,markerclusterer

I am trying to fix the problem with out success.

As you can see when you uncheck the VDSL or ADSL option the markercluster still having the same value.

downloadUrl("php_to_xml.php", function(data) {
        var xml = data.responseXML;
        var markers = xml.documentElement.getElementsByTagName("marker");
        for (var i = 0; i < markers.length; i++) {
            var ThisMarkers = markers[i];
            var lat = markers[i].getAttribute("lat");
            var lng = markers[i].getAttribute("lng");
            var typeofkafao = markers[i].getAttribute("typeofkafao");
            var type = markers[i].getAttribute("type");
            var point = new google.maps.LatLng(
                parseFloat(markers[i].getAttribute("lat")),
                parseFloat(markers[i].getAttribute("lng")));
            var icon = coloredRideshareIcon(typeofkafao);       
            //below is the balloon of the marker.
            var marker = new google.maps.Marker({
                map: map,
                position: point,
                icon: icon
            });
            addMarker(typeofkafao, marker, map, infoWindow, ThisMarkers);
        }
        var mcOptions = {gridSize: 40, maxZoom: 15};
        var markerCluster = new MarkerClusterer(map,gmarkers,mcOptions); // edo trexi
    });

function downloadUrl(url, callback) {
    var request = window.ActiveXObject ?
        new ActiveXObject('Microsoft.XMLHTTP') :
        new XMLHttpRequest;

        request.onreadystatechange = function() {
            if (request.readyState == 4) {
                request.onreadystatechange = doNothing;
                callback(request, request.status);
            }
        };

    request.open('GET', url, true);
    request.send(null);
}

I know that the problem is on the downloadUrl function because its async. I have to call the markerCluster outside the downloadUrl but I cant because I cant send the markers variables outside the downloadUrl function.

I think the problem is fix with something like that but not exactly like that.

var markers2;
downloadUrl("php_to_xml.php", function(data) {
        var xml = data.responseXML;
        var markers = xml.documentElement.getElementsByTagName("marker");
        markers2 = markers;
    });

for (var i = 0; i < markers2.length; i++) {
    var ThisMarkers = markers2[i];
    var lat = markers2[i].getAttribute("lat");
    var lng = markers2[i].getAttribute("lng");
    var typeofkafao = markers2[i].getAttribute("typeofkafao");
    var type = markers2[i].getAttribute("type");
    var point = new google.maps.LatLng(
        parseFloat(markers2[i].getAttribute("lat")),
        parseFloat(markers2[i].getAttribute("lng")));
    var icon = coloredRideshareIcon(typeofkafao);       
    //below is the balloon of the marker.
    var marker = new google.maps.Marker({
        map: map,
        position: point,
        icon: icon
    });
    addMarker(typeofkafao, marker, map, infoWindow, ThisMarkers);
}
var mcOptions = {gridSize: 40, maxZoom: 15};
var markerCluster = new MarkerClusterer(map,gmarkers,mcOptions); // edo trexi

function downloadUrl(url, callback) {
    var request = window.ActiveXObject ?
        new ActiveXObject('Microsoft.XMLHTTP') :
        new XMLHttpRequest;

        request.onreadystatechange = function() {
            if (request.readyState == 4) {
                request.onreadystatechange = doNothing;
                callback(request, request.status);
            }
        };

    request.open('GET', url, true);
    request.send(null);
}

Any ideas guys?

Thanks a lot


Answer:

A look into the console would have been useful:

ReferenceError: markerCluster is not defined

the markerCluster-variable isn't accessible in Markers()

remove var-keyword:

 
  var
  markerCluster = new MarkerClusterer(map,gmarkers,mcOptions);

Related:


Android Google Maps is blank in release mode


android,google-maps
The normal solution to this posted problem is that the SHA1 key is different for the release version and needs to be changed on the google developer console. I updated it and cannot get it to work. My Google Maps API_KEY currently allows any android application in (the Android applications...

Raty Star rating in Google map infowindow


javascript,google-maps,google-maps-api-3,infowindow,raty
I have added marker on google map with some search results. var infowindow = new google.maps.InfoWindow(); var marker, i; for (i = 0; i < locations.length; i++) { var contentString="";var image_path1=""; contentString += '<div class="browse-map-venue" style="padding:5px;width: 230px;">'; contentString += '<div class="rating" style="float: right; padding-right: 10px;">'; contentString += '<script type="text/javascript" src="<?php...

Google map get center does not return valid longitude


javascript,php,google-maps
I am working with google map.i am facing issue When I have dragged the map to reach to the -180 longitude, after dragging so far to the left side. If I click on "Get center" button it is giving wrong longitude. var map; function initialize() { var mapOpt = {...

Load Google Maps in a tab when tab is picked, and not from begining


java,android,google-maps,android-fragments,tabs
I have a TabLayout with 2 tabs. First tab ( Main tab ) is a list of store in a listview Second tab is the same list in a Google Maps. I noticed that When I go by default in the first tab ( list ), the GPS icon appears...

Google Maps v2 for Android map tiles overlapping


android,google-maps,mapbox
I use custom UrlTileProvider to load tiles from MapBox. public class MapboxTileProvider extends UrlTileProvider { public MapboxTileProvider(int width, int height) { super(width, height); } @Override public URL getTileUrl(int x, int y, int z) { try { return new URL(String.format(MAP_BASE_URL, z, x, y)); } catch (MalformedURLException e) { throw new RuntimeException("Failed...

google maps refresh without displaying gray


javascript,jquery,mongodb,google-maps,google-maps-api-3
I am using the Google Maps API v3 in javascript, and I am constantly reloading the map with an app.get, and adding layers and bookmarks using mongodb. To erase everything I reload the map, and while it's loading a gray background displays in the div that contains the map. What...

ANDROID PLACE_PICKER (builder.build(context)


android,google-maps,google-places-api
Basically I am trying to implement a PLACE_PICKER for Android and I am getting this confusing error here: int PLACE_PICKER_REQUEST = 1; PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder(); Context context = getApplicationContext(); startActivityForResult(builder.build(context), PLACE_PICKER_REQUEST); The error is coming in line 4:" (builder.build(context), " and I have no idea why, I am...

Google Maps Error - Android app ¦¦ v2


android,google-maps,android-maps-v2
I'm trying to add a map to my layout on an android app but I get the below code: 06-16 20:51:06.142 17581-17581/wk.gon250.dublinbike E/AndroidRuntime﹕ FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{wk.gon250.dublinbike/wk.gon250.dublinbike.StationDetailsActivity}: android.view.InflateException: Binary XML file line #16: Error inflating class fragment at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2266) at...

Retrive geolocation in real time (HTML5)


javascript,html5,google-maps,gps,geolocation
I have this code: var map; var geocoder; function initialize() { var mapOptions = { zoom: 18 }; map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); // Try HTML5 geolocation if(navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { var pos = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); var marker = new google.maps.Marker({ position: pos, map: map, title: 'Posizione Attuale' });...

Creating a text input field precisely where a user clicks on a Google Map


google-maps,google-maps-api-3
Right now I have a Google Map which places a mapLabel that says "Hello!" wherever a user clicks (and binds it to that Lat/Long) This is done simply by google.maps.event.addListener(map, 'click', function(e) { placeLabel(e.latLng, map); }); and function placeLabel(position, map) { var mapLabel = new MapLabel({ text: 'Hello!', position: position,...

R stops displaying maps


r,google-maps,ggmap
Few days ago I was familiarizing myself with displaying maps, plotting points on the map from http://rpubs.com/nickbearman/r-google-map-making Today, I have intermittent success in displaying maps. library(ggmap) map <- qmap('Anaheim', zoom = 10, maptype = 'roadmap') Outputs Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=Anaheim&zoom=10&size=640x640&scale=2&maptype=roadmap&language=en-EN&sensor=false And when I go to the URL...

How to plot data points at particular location in a map in R


r,google-maps,ggmap
I have a dataset that looks like this: LOCALITY numbers 1 Airoli 72 2 Andheri East 286 3 Andheri west 208 4 Arya Nagar 5 5 Asalfa 7 6 Bandra East 36 7 Bandra West 72 I want to plot bubbles (bigger the number bigger would be the bubble) inside...

how to use geocoder class to retrieve latitude and longitude through ajax


javascript,ajax,google-maps
the json array which contains the list of addresses [ { "id": 0, "title": "Coop.Sociale Prassi e Ricerca Onlus", "latitude": 0, "longitude": 0, "address": "Viale Eleonora D'Arborea 12, Roma, IT" }, { "id": 0, "title": "San Lorenzo", "latitude": 0, "longitude": 0, "address": "Viale della Primavera 330, Roma, IT" },...

HTML5, geolocation in real time with marker


javascript,html5,google-maps-api-3,marker
I have this code: function startTracking() { var trackId = navigator.geolocation.watchPosition(successCallback, null, {maximumAge:1000, timeout:60000, enableHighAccuracy:true}); function successCallback(position){ map.panTo(new google.maps.LatLng(position.coords.latitude, position.coords.longitude)); var marker = new google.maps.Marker({ position: new google.maps.LatLng(position.coords.latitude, position.coords.longitude), map: map, title: 'Posizione Attuale' }); marker.setMap(map); }; } Now the app create a marker every time that I move. I...

Using maps on api 21+ inside of tab


android,google-maps,android-fragments
I am just working on an application trying to learn a lot of the newer technology with API 21 / API 22. I am relatively new to android In general, but just want to make sure I am doing everything the up to date way. In my app I have...

Accessing Coordinates in Nested JSON File


javascript,jquery,json,google-maps
I'm trying to access lat/lng of polygons within a nested JSON file and trying to draw them using new google.maps.Polygon(), but having some troubles. UPDATE-2: I am able to draw polygons, but it only draws the first polygon, not all 3: http://jsfiddle.net/vprbqaLm/10/ UPDATE: Check out my latest JSFiddle here: http://jsfiddle.net/vprbqaLm/9/...

How to permanently change behavior of markers for app?


android,google-maps,marker
I want to make it so that when a user creates a marker in google maps, it is able to be double clicked (or held on or something) and bring up a new Activity. Right now I have it so that I create a marker on the map manually and...

How to implement centered marker in Google Maps API v3 with Ionic & Angular


javascript,angularjs,google-maps,google-maps-api-3,ionic
I have created a map in my Ionic project using Maps API v3 and ngCordova to get my current location and with the following code: var options = {timeout: 10000, enablehighAccuracy: false}; $cordovaGeolocation.getCurrentPosition(options) .then(function (position) { var myLat = position.coords.latitude; var myLong = position.coords.longitude; console.log(myLat, myLong); var center = new...

Create a unique URL for linking to data pulled from a database [closed]


javascript,html,sql,google-maps,maps
Is it possible to create a unique URL to link to information that is called and displayed from a database? [I am struggling to articulate this question, so any suggestions for revising it are welcome.] Specifics: I have a page that includes an embedded map and related information about each...

Using variables for longitude and latitude with google maps api


javascript,google-maps
I've just started using the google maps API for browsers but I can't seem to get it to work when I place variables in the longitude/latitude places instead of numbers directly. I need the maps to populate from the value of two input elements. It doesn't work with variables but...

stuck making a data frame after using street2coordinates (R)


r,google-maps,ggplot2
I am trying to follow the tutorial outlined here but having trouble But I am running into a problem at this step: my_crime <- data.frame(year=my_crime$Year, community=my_crime$Community.Area, type=my_crime$Primary.Type, arrest=my_crime$Arrest, latitude=my_crime$Latitude, longitude=my_crime$Longitude) My equivalent step is: geocode <- data.frame(latitude=geocode$lat, longitude=geocode$long) I get the following error: Error in geocode$lat : $ operator is...

Google Map Direction using comgooglemaps


ios,google-maps,directions
I am using google map directions I am trying that code but it doesn't work if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"comgooglemaps://"]]) { [[UIApplication sharedApplication] openURL: [NSURL URLWithString:@"comgooglemaps://?center=40.765819,-73.975866&zoom=14&views=traffic"]]; } else { NSLog(@"Can't use comgooglemaps://"); } There is always message that "Can't use comgooglemaps:// Is There any additional setting to use this....

Google map v3 remove last line from poliline


google-maps-api-3
My script adds markers to the map. When I want remove the last I click back button http://tests.uk4u.pl/goomap/goomap_markers/ Everything works OK but I started something similar with poliline. After many possible changes of my code I cant achieve the same like with my markers. I want remove last line of...

Touch events for google maps on mobile


javascript,jquery,google-maps,google-maps-api-3
In my app I am using google maps and I am creating locations on the maps once the user right clicks. I have this event doing the trick for me google.maps.event.addListener(map, 'rightclick', function (e) { if (checkDistance(e.latLng)) { if (viewModel.haveRolesToDoStuffOnProjectLevel()) { geocoder.geocode({ location: e.latLng }, function (result) { if (result.length...

Android Studio: cannot upgrade google play services


android,google-maps,android-studio,google-play-services,google-play-developer-api
I have tried download the latest version on the sdk manager, but is still not working. I have seen other posts telling users to enter the following... compile 'com.google.android.gms:play-services:4.2.+' I do not understand where to enter it. I tried in the terminal feature of the android studio but it gives...

Add or Remove Polygons Based on Zoom Levels


javascript,google-maps
I am trying to add and remove polygons based on the zoom levels in Google Maps. This is what I am using to detect the zoom change in order to add or remove the polygons. google.maps.event.addListener(map, 'zoom_changed', function () { if (map.getZoom() <= 13) { polygons.setMap(null); } else { polygons.setMap(map);...

Change the URL of a KML file that Google Maps references on button click


javascript,google-maps
I would like to initially display an 8 Day Average KML file in Google Maps on first page load, but allow the user to click the "1 Day" and "3 Day" button to have Google Maps reference those instead of the "8 Day". The goal is to create a mini...

mapFragment.getMapAsync(this) - NullPointerException


android,google-maps,android-maps-v2
I am using com.google.android.gms:play-services-maps:7.5.0 version of Google Maps services. When trying to call the below I get java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.maps.SupportMapFragment.getMapAsync(com.google.android.gms.maps.OnMapReadyCallback)' on a null object reference. @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { SupportMapFragment mapFragment = (SupportMapFragment) getActivity().getSupportFragmentManager()...

Google Maps adding marker from ajax using jquery


javascript,jquery,google-maps,google-maps-api-3
I am trying to add google maps to my web page, the web page has div with id of radar with width specified. I get coordinates from a second page using jquery ajax method, and plot them on the map using Marker. But only the last marker is displayed nothing...

GeoGoogle - Google Geocoder Java API


java,google-maps,geolocation,geocoding
Is still valid this project or it is deprecated ? I got a 404 Error checking the examples http://code.google.com/apis/maps/documentation/index.html#Geocoding_Examples

Initializing google map depending on form results


javascript,ruby-on-rails,ajax,google-maps
So I have a form with just a select field. Depending on what the user selected markers will get rendered through AJAX on the map. The thing is how to initialize the function and create the map. I just found that people are doing it this way: google.maps.event.addDomListener(window, 'load', initialize);...

New Google Maps query string syntax for a marker


google-maps,query-string
In my web page code, I used to have a link to open a new window with Google Maps initialized like this: http://maps.google.com/maps?q=loc:{{lat}},{{long}}&z=14 and it was showing a marker. With the new google maps, this syntax does not work completely, as the zoom level is not taken into account. So...

How to integrate SQLite with AngularJS?


angularjs,sqlite,google-maps
I'm doing an angularjs app using google maps api v3 and a plugin called ng-map. But I want to store some coordinates in a SQLite database and then retrieve from the app.

Google map infowindow position


javascript,google-maps,events,infowindow
Here is a sample google map with three polygons. I am setting the infowindow for each polygon as, for (var i in coordinates) { arr = []; for (var j=0; j < coordinates[i].length; j++) { arr.push( new google.maps.LatLng( parseFloat(coordinates[i][j][0]), parseFloat(coordinates[i][j][1]) )); bounds.extend(arr[arr.length-1]) } // Construct the polygon. polygons.push(new google.maps.Polygon({ paths:...

how can i plot a route map?


javascript,google-maps,plot
I am writing a simple application to plot multiple marker in the google map and connect it thought a path as it looks like a route . I can plot multiple marker . and search some article which plot the route map . but i can not plot it ....

Google map infowindow position on custom marker


javascript,css,google-maps,google-maps-api-3
I'm not using the Markers in Google Maps because I wish to render custom text and images on my marker, so what I did is a custom marker using Overlays. The Overlay position is not exactly like the marker so I played a bit with it and now it is...

Android SharedPreference Ghost Number?


android,google-maps-api-3,sharedpreferences
I am losing my mind, I am using shared preference to create google maps markers, and it is getting coordinates from a 2130 line long text document but something is really off, here is the coordinates it is getting around line 1982 06-16 23:23:10.072 22228-22228/com.emiliogaines.fuelfinder D/X:﹕ 12.0434 990 06-16 23:23:10.072...

Dynamically change Google Maps icon by type in array data


javascript,arrays,google-maps,google-maps-api-3
I am completely new to javascript and have been tasked with converting an old jvector map to the google maps API. I think i'm doing pretty well so far! I've managed to get the map to populate with all the right markers in all the assigned spots, with nice shiny...

Uncaught error: Invalid type for google table column


javascript,json,google-maps,google-visualization
I recently started using google visualization due to its simplicity. But while implementing in my recent project i seem to have run into a bit of trouble. The program shown is used to pull data from a JSON object and utilize it to display data in the google tables. Now...

ACF Multiple Map Markers


wordpress,google-maps,google-maps-api-3,acf
I'm using Advanced Custom Fields and want to pull in the field called 'location' to display some locations on a map. How would i adjust the following code to display multiple markers from my location field? The format of the custom field is like so: echo 'Location: ' . get_field('location');...

How to add a multiple marker to a moving location google map,Javascript


javascript,google-maps-api-3
I'm trying to make a function that adds a marker based on coordinates given to it,but its seems that the simple thing which adding a single position is not working,other than the current position marker to Google map,since the map is keep updating itself over and over the marker will...