capacitor-community / google-maps

Capacitor Plugin using native Google Maps SDK for Android and iOS.
https://capacitor-community.github.io/google-maps/
MIT License
152 stars 64 forks source link

Added Polyline Feature for android #220

Open Timileyin105 opened 1 year ago

Timileyin105 commented 1 year ago

Added Polyline Feature for android

usage

  CapacitorGoogleMaps.addPolyline ({
        mapId: this.currentMapId,
        path: [], // polyline path
        preferences: {
            color:  '#ffff', // line color
            width: 7, // line width
            isGeodesic: true
        }
   })

i have tested this to work i added the remove polyline also but this doesnt seem to work for me, not sure why, i make another pull if i am able to fix and when i also do for ios thanks

WynOwen72 commented 1 year ago

@Timileyin105 Thank you for doing this. Is there an idiot proof way of importing your code? TIA

Timileyin105 commented 1 year ago

Hi @WynOwen72 run npm install https://github.com/Timileyin105/capacitor-native-google-map.git

Timileyin105 commented 1 year ago

@WynOwen72 didn't hear any update from you were you able to install and use it ?

CapacitorGoogleMaps.addPolyline ({
        mapId: this.currentMapId,
        path: [], // polyline path
        preferences: {
            color:  '#ffff', // line color
            width: 7, // line width
            isGeodesic: true
        }
 })
WynOwen72 commented 1 year ago

Good morning, it installed OK. Today's plan is to try and implement it in a basic form and then integrated it in my app.

Grazie.

Timileyin105 commented 1 year ago

Alright, i will be done soon with the android app i'm using the map on so soon i will working on the ios to also make use of it

WynOwen72 commented 1 year ago

I'm getting an error. Maybe it is a silly mistake from me:

My code: `const showpolyline = () => { if ( exampleMapId.value != null){ const coordinates = [ { lat: -34.367, lng: 150.644 }, { lat: -34.368, lng: 150.644 }, { lat: -34.369, lng: 150.644 }, ];

CapacitorGoogleMaps.addPolyline ({
    mapId:  exampleMapId.value,
    path: coordinates, // polyline path
    preferences: {
        color:  '#ffff', // line color
        width: 7, // line width
        isGeodesic: true
    }

})} else { console.log('No mapid')} }` Error: image

Timileyin105 commented 1 year ago

hello @WynOwen72 if you check the LatLng interface image what was used there wasnt lat & lng but latitude and longitude so this should be

const coordinates = [
    { latitude: -34.367, longitude: 150.644 },
    { latitude: -34.368, longitude: 150.644 },
    { latitude: -34.369, longitude: 150.644 }
];

image

WynOwen72 commented 1 year ago

@Timileyin105 I can confirm it works. Screenshot_1684944778

Timileyin105 commented 1 year ago

@WynOwen72 OK, happy coding

szymusu commented 1 year ago

Hi @Timileyin105 good work, works fine for me on Android but fails to build on iOS.

I created a new capacitor app using commands:

npm init @capacitor/app npm install

than added iOS platform:

npm install @capacitor/ios npx cap add ios

added your package:

npm install https://github.com/Timileyin105/capacitor-native-google-map.git

but when I try to run: npm run build npx cap sync npx cap run ios

I get these errors:

/Users/marcin/Code/polyline_test/polyline/node_modules/@capacitor-community/google-maps/ios/Plugin/Plugin.swift:345:33: error: extra arguments at positions #2, #3 in call self.addPolyline([ ^ /Users/marcin/Code/polyline_test/polyline/nodemodules/@capacitor-community/google-maps/ios/Plugin/Plugin.swift:333:16: note: 'addPolyline' declared here @objc func addPolyline( call: CAPPluginCall) { ^ /Users/marcin/Code/polyline_test/polyline/node_modules/@capacitor-community/google-maps/ios/Plugin/Plugin.swift:345:34: error: cannot convert value of type '[String : Any]' to expected argument type 'CAPPluginCall' self.addPolyline([ ^ /Users/marcin/Code/polyline_test/polyline/node_modules/@capacitor-community/google-maps/ios/Plugin/Plugin.swift:359:42: error: value of type 'CapacitorGoogleMaps' has no member 'customPolylines' if let customPolyline = self.customPolylines[polylineId] {



can someone help?
is that a configuration fault on my part? or a legitimate issue?
simulator: iPhone 14 Pro iOS 16.4