How to addShape () on google map with jquery-ui-map correctly

I use the following code to add a shape to a map using jquery, jqueryui-map and google maps API

$('#map_canvas').gmap('getCurrentPosition', function(position, status) {
            if ( status === 'OK' ) {
                var clientPosition = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
                $('#map_canvas').gmap('addMarker', {'position': clientPosition, 'bounds': false});
                $("#map_canvas").gmap("option", "center", clientPosition);
                $('#map_canvas').gmap('option', 'zoom', 14);
                $('#map_canvas').gmap('addShape', 'Circle', {
                    'strokeColor': "#008595",
                    'strokeOpacity': 0.8,
                    'strokeWeight': 2,
                    'fillColor': "#008595",
                    'fillOpacity': 0.35,
                    'center': clientPosition,
                    'radius': 50,
                    'clickable': false });
            }
});

I also tried calling the .addShape method in $ ('# map_canvas'). but I get only the following error:

Uncaught TypeError: Cannot call method 'apply' of undefined jquery.ui.map.js:46
$.a.$.fn.(anonymous function) jquery.ui.map.js:46
e.extend.each jquery.min.js:2
e.fn.e.each jquery.min.js:2
$.a.$.fn.(anonymous function) jquery.ui.map.js:40
(anonymous function) :8080:397
$.extend.getCurrentPosition

Does anyone know how to solve this problem? The example on http://jquery-ui-map.googlecode.com/svn/trunk/demos/jquery-google-maps-geolocation.html works for some reason .. I just canโ€™t understand the real difference. Maybe I'm blind right now;)

Thank,

Pat

+5
source share
3 answers

Had the same problem generated by the same documentation that was not mentioned to include jquery.ui.map.overlays.js

The code says

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script type="text/javascript" src="PATH_TO_PLUGIN/jquery.ui.map.js"></script>
<script type="text/javascript" src="PATH_TO_PLUGIN/jquery.ui.map.extensions.js"></script>

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script type="text/javascript" src="PATH_TO_PLUGIN/jquery.ui.map.js"></script>
<script type="text/javascript" src="PATH_TO_PLUGIN/jquery.ui.map.overlays.js"></script>

, jquery.ui.map.extensions.js

+7

jquery.ui.map.extensions.js jquery.ui.map.overlays.js,

<script type="text/javascript" charset="utf-8" src="js/jquery-1.9.1.min.js"> </script> 
<script type="text/javascript" src="js/jquery.ui.map.js"></script> 
<!--script type="text/javascript" src="js/jquery.ui.map.extensions.js"></script--> 
<script type="text/javascript" src="js/jquery.ui.map.overlays.js"></script>

, Object # getCurrentPosition.

jquery.ui.map.extensions.js, .

<script type="text/javascript" charset="utf-8" src="js/jquery-1.9.1.min.js"> </script> 
<script type="text/javascript" src="js/jquery.ui.map.js"></script> 
<script type="text/javascript" src="js/jquery.ui.map.extensions.js"></script> 
<script type="text/javascript" src="js/jquery.ui.map.overlays.js"></script>

Moak!! .

+1

it should be like this:

<script type="text/javascript" src="jquery/2.1.0/jquery-2.1.0.min.js"></script>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=true"></script>
<script type="text/javascript" src="jquery-ui-map/3.0-rc/ui/min/jquery.ui.map.min.js"></script>
<script type="text/javascript" src="jquery-ui-map/3.0-rc/ui/jquery.ui.map.extensions.js"></script>
<script type="text/javascript" src="jquery-ui-map/3.0-rc/ui/jquery.ui.map.overlays.js"></script>
0
source

All Articles