mapsplugin / cordova-plugin-googlemaps Goto Github PK
View Code? Open in Web Editor NEWGoogle Maps plugin for Cordova
License: Apache License 2.0
Google Maps plugin for Cordova
License: Apache License 2.0
map.getCameraPosition didn't work drung camerachange event, even try after map init also failure cause undefine function exception. and it will let map can't run anymore. By the way, I only try it on IOS emulator.
When the following code is used the marker does not fire the click event:
map.addMarker({
icon: icon,
position: new plugin.google.maps.LatLng(stops[i].latitude, stops[i].longitude),
}, function(marker) {
marker.addEventListener(plugin.google.maps.event.MARKER_CLICK, function(){
alert("HELLO!");
});
Also, it might be better to use the 'touchend' event to bind as this will respond much faster than click.
I'd really like to animate the position of the map view. The scenario I'm imagining is that the user presses a button and the map slides to the right to reveal a menu hidden underneath the map (displayed in the cordova web view).
I've looked at the code, and it seems to me that the logical place to put support for this on the JS side would be to add an "animated" flag to the map.refreshLayout method. I guess that the animation duration could be a default value which could get overridden in params passed into the getMap method.
Hey there again. We needed a function to get the lat lng boundaries the map is currently showing and figured others may need it too so I'm sharing the code with you:
_ANDROID_*
@SuppressWarnings("unused")
private void getVisibleRegion(final JSONArray args, final CallbackContext callbackContext) {
try {
final VisibleRegion visibleRegion = map.getProjection().getVisibleRegion();
final LatLngBounds latLngBounds = visibleRegion.latLngBounds;
final JSONObject result = new JSONObject();
final JSONObject northeast = new JSONObject();
final JSONObject southwest = new JSONObject();
northeast.put("lat", latLngBounds.northeast.latitude);
northeast.put("lng", latLngBounds.northeast.longitude);
southwest.put("lat", latLngBounds.southwest.latitude);
southwest.put("lng", latLngBounds.southwest.longitude);
result.put("northeast", northeast);
result.put("southwest", southwest);
callbackContext.success(result);
} catch (final JSONException e) {
// TODO Handle exception
throw new RuntimeException("Unhandeled Exception!", e);
}
}
_END_ANDROID_*
_iOS_*
- (void)getVisibleRegion:(CDVInvokedUrlCommand*)command {
GMSVisibleRegion visibleRegion = self.mapCtrl.map.projection.visibleRegion;
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithRegion:visibleRegion];
NSMutableDictionary *json = [NSMutableDictionary dictionary];
NSMutableDictionary *northeast = [NSMutableDictionary dictionary];
[northeast setObject:[NSNumber numberWithFloat:bounds.northEast.latitude] forKey:@"lat"];
[northeast setObject:[NSNumber numberWithFloat:bounds.northEast.longitude] forKey:@"lng"];
[json setObject:northeast forKey:@"northeast"];
NSMutableDictionary *southwest = [NSMutableDictionary dictionary];
[southwest setObject:[NSNumber numberWithFloat:bounds.southWest.latitude] forKey:@"lat"];
[southwest setObject:[NSNumber numberWithFloat:bounds.southWest.longitude] forKey:@"lng"];
[json setObject:southwest forKey:@"southwest"];
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:json];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
_END_iOS_*
***_JAVASCRIPT_
getVisibleRegion = function(successCallback, errorCallback) {
cordova.exec(successCallback, self.errorHandler, PLUGIN_NAME, 'exec', ['Map.getVisibleRegion']);
};
***_END_JAVASCRIPT_
Want To Remove All markers When Google Map Window is Close.
Dear Masashi Katsumata,
map window does not have any close event ?
Thanks
Best Regards
Saad Mehmood
Dear Masashi Katsumata,
I am using Intel App Framework
An Error Occured When i create maps
TypeError : Cannot read Property 'offsetWidth' of null
Thanks
Best Regards
Saad Mehmood
const GOOGLE_SYDNEY = new plugin.google.maps.LatLng(-33.867487,151.20699);
map.addMarker({
'position': GOOGLE_SYDNEY,
'draggable': true //<--- does not work on Android
});
I get the following error when I click "Init a map" for the second time, after closing the initial map:
Java Error
android.widget.FrameLayout$LayoutParams cannot be casted to android.widget.AbsoluteLayout$LayoutParams
Any help? I could help fixing this if I had any idea how to recompile the plugin...
Dear Masashi Katsumata,
I really appreciate your work and everybody know its best plugin of Google maps.
but the problem is i add this plugin by CLI
=>cordova plugin add \phonegap-googlemaps-plugin-master --variable API_KEY_FOR_ANDROID="Google Simple API Key"
=>cordova plugin add com.google.playservices
i compiled the cordova project and run on my android device it work good.
but when i add more plugin like device,motion,camera,etc
an error occurred state Class not found.
Thanks
Best Regards
Saad Mehmood
I am attempting to install the phonegap-googlemaps-plugin via the instructions linked below:
https://github.com/wf9a5m75/phonegap-googlemaps-plugin/wiki/Tutorial-for-Mac
The installation seems to go well but when I try to build by project I get the following build error:
'GoogleMaps/GoogleMaps.h' file not found
map.addMarker({
'position': new plugin.google.maps.LatLng(sessionStorage.currentLatitude, sessionStorage.currentLongitude),
'draggable': true
}, function(marker) {
marker.setDraggable(true);
marker.addEventListener(plugin.google.maps.event.MARKER_DRAG_END, function(marker) {
marker.getPosition(function(latLng) {
marker.setTitle(latLng.toUrlValue());
marker.showInfoWindow();
});
});
});
It's probably not possible to embed the map into a view, but is there the ability to adjust the layout of the overlay to make it appear to be part of a view?
Hi, first thank you for the plugin. It works great! But I’m experiencing one issue both in my app and the sample SimpleMap apk on Android phone. After the map shows, Phonegap will lose control over the back button. Then every back button press closes the whole application. I’m not sure if it is an issue of the Phonegap or the plugin. Do you know any solution for this? Thanks.
In the constructor of the mentioned GoogleMapsViewController.m "initOptions" field is initialized with a reference to the passed "options param:
In order to avoid BAD_ACCESS in "- (void)viewDidLoad" options should be copied using
initOptions = [[NSDictionary alloc] initWithDictionary:options];
There may be a better solution but this worked for me.
Hi, i need to put a image over the map in order to keep it always in the center at the map. Also i need to set a button over the map. How can i do that?
Hi,
first let me thank you for this plugin. It's awesome and makes us happy, espacially when coming from the JavaScript Version of GoogleMaps.
I want to ask what general hints you have when we want to add a search bar over the map and show search results in front of the map? Do you already implement something like that? We struggle with layouting the view.
Thanks in advance.
The marker rotation
property and the setRotation()
method have no effect on markers.
Also, using setPosition()
on a marker on iOS (iPhone 5) immediately crashes the application as soon as it is invoked.
Hi!
I use phonegap instead of cordova.
I do step by step "Tutorial for Windows".
At 5 step i use command:
phonegap plugin add plugin.google.maps --variable API_KEY_FOR_ANDROID="HERE_MY_KEY"
but only get
[phonegap] adding the plugin: plugin.google.maps
[Error: Variable(s) missing: API_KEY_FOR_ANDROID]
[error] Variable(s) missing: API_KEY_FOR_ANDROID
in terminal.
Hello.
Excellent plugin, really love using it.
Is it possible for you to put Direction features
Thanks
I think it is feature, but before that, can I did it by java script code?
Tried the basic IOS tutorial - twice - and could not get it to work. Cordova 3.4.1-0.1.0. xCode 5.1.1. API set up + key. GoogleMaps-iOS-1.7.2 sdk (for manual attempt).
Missing files (wrong places it seems). Compilation errors. Really wanted this to work. Started through the "manual process" but got lost at the AppDelegate step and files not matching.
Is there any hope for this to work / get fixed?
Thanks, Randy
I have using cordova 3.4.1 to build android app.Because of the navigator.geolocation.getCurrentPosition
function sometimes not working,I must reboot my phone often to use it.
So I install the phonegap-googlemaps-plugin
, I have installed it successful and see the google map in android,but the map.getMyLocation
function never fire callback, and I can't get my location.
I am sure I have turn on the device's all the gps settings.
My android version is 4.1.2.
here is my code below, why it not works?
var onDeviceReady = function(){
window.map = plugin.google.maps.Map.getMap();
alert(typeof map); //execute
alert(typeof map.getMyLocation); //execute
map.addEventListener(plugin.google.maps.event.MAP_READY, function(map){
alert('map init');//execute
map.showDialog();//execute I can see the earth map
map.getMyLocation(function(location) {
alert('get location'); //never execute
alert(typeof location);//never execute
alert(JSON.stringify(location));//never execute
alert(location.latLng.lat);//never execute
alert(location.latLng.lng);//never execute
});
});
}
document.addEventListener('deviceready', onDeviceReady, false);
Thank you for build the plugin.
The moveCamera
and animateCamera
events fire immediately. For example, if I animate the camera with a duration of 3000 milliseconds, if I put an alert inside the callback it fires immediately proving that the duration has not been elapsed.
There is code inside GoogleMaps.m _removeMapView that re-adds a map view when the map is embedded (lines 201-206 in current code). Therefore if, in JS, you call map.closeDialog() the map will get removed and then instantly re-added - basically you see the map re-draw itself.
I'd suggest that this code should be removed, and that closeDialog should remove the map from the screen.
Is there an event that fires after the map has been moved?
For example:
Hey guys,
seems like a very good pluggin. I've followed the install process step by step and when doing the following command:
cordova plugin add plugin.google.maps --variable API_KEY_FOR_ANDROID="YOUR_ANDROID_API_KEY_IS_HERE" --variable API_KEY_FOR_IOS="YOUR_IOS_API_KEY_IS_HERE"
With my own credentials, nothing happen in the command line but a ">" added at the following line :
YohannM$ cordova plugin add plugin.google.maps --variable API_KEY_FOR_ANDROID="AI***************" --variable API_KEY_FOR_IOS=“AI********************"
`>
What should I do from here ?
Note:
the "`" before the ">" sign is here only to have the sign shown otherwise this forum understand it as a citation
when doing echo $JAVA_HOME I can't see anyting but I've installed it properly
when doing which android I don't have anything but I have installed eclipse and SDK properly form the official doc.
I'm working with mac osx 10.9
thanks
Is it possible to add option to map.showDialog(); in the Javascript to arrange the map in a specific location on the screen.
eg:
map.showDialog({
position: {
landscape: {
top: "20px",
bottom: "10px"
},
portrait: {
top: "30px",
bottom: "0"
}
}
});
I saw the code and found there is a camera idle, does it support now or feature?
Hi.
HTML select box items are suddenly disappearing after appearing for 1-2 seconds,this is only happening when i include the map plugin.
i have tested by deleting the map plugin and it works, any workaround for this.
Thanks
Hi,
Nice work, but i'd like to know how to implement Gmap Libraries such as PlaceService, should i use javascript or you need to implement it in your plugin ?
Hi,
I followed step by step the installation instruction.
However once in Xcode if i try to build the project I get an error at line 93 dispatch_release(gueue);
The message state:
ARC forbids explicit message send of 'release'
'release' is unavailable: not available in automatic reference counting mode
Here the screenshot of the error.
Mac Book Pro OSX 10.9.2
Xcode Version 5.1 (5B130a)
Dear Masashi Katsumata,
Does it support cluster markers ?
Thanks
Best Regards
Saad Mehmood
var polygon = new plugin.google.maps.Polygon();
polygon.remove();
Does not work the above code.
There is no way to do the below in v1.0.9
map.getBounds().contains(marker.getPosition())
Hi
Can we render html code in snippet? i mean any image tag / link etc
Hi you,
i interested your plugin, but i can not install in android. You can detail use guide install android !
Tks you, wish you a good day !
Hello
On iOS 6 is the closebar at the bottom not fully visible. There are 20px (40px on Retina-Display) margin. I Think, it’s because the Statusbar on iOS 7 ist not there.
Is there any Workaround for this?
Thanks in advance.
It appears there is no map.getZoom method to retrieve the current zoom level.
With GoogleMaps you can zoom with CameraUpdateFactory.newLatLngBounds so that a group of locations are all visible. It also supports defining a margin in pixels to leave clear in the corners of the map, so that the furthest away locations are not directly at the edges of the screen. This is a highly useful feature in many cases, so I would recommend implementing it :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.