Convert a Google Earth KmlPolygon into KML string - google-earth-plugin

If I have a KmlPolygon object, how might I convert this to a KML string? This functionality would allow you to save whatever has been modelled and use it as a layer in Google Earth desktop for instance, or even load it back into the web plugin.
EDIT
This would do the opposite of fetchKml.

Found it. You can use the getKml() function of KmlFeature to return the KML string. You can also add multiple KmlPolygon objects by constructing a KmlDocument using the dom.buildDocument() of the utility library, and then using getKml() on that.

Related

Here API | MultiValueQueryParameter for Via Points

I'm using the latest version of the here javascript sdk 3.1.32.0
When I use H.service.Url.MultiValueQueryParameter for my via points like
{
...,
via: new H.service.Url.MultiValueQueryParameter(['50.1234,8.7654', '51.2234,9.1123']);
}
I see in the URL params of my request this: &via=%5Bobject%20Object%5D
Someone an idea why this happens?
Thanks in advance!
When you use "via" parameter, you define a list of via waypoints. A via waypoint is not a native datatype recongnized by JavaScript, therefore, you will see in the URL params the word object refering to a particular data structure, in this case the via Waypoint composed mainly by Latitude, Longitude.
Regards.
This took a while to figure out the actual issue with the malformed url params. I was dynamically loading the here maps service script on mount of a component. Accidentally this happened in some cases twice. In both cases H was globally available and everything worked like expected. BUT when the script was loaded twice H.service.Url.MultiValueQueryParameter didn't return the correct params. It basically encoded them twice, or tried to.
The other side issue was that https://www.npmjs.com/package/#types/heremaps is outdated and doesn't cover MultiValueQueryParameter. So I had to remove the types and use my own. Else I probably would have realized the issue earlier.

How to use tidyGeocoder with custom geocoder?

I have the following geocoder service: https://geodata.md.gov/imap/rest/services/GeocodeServices/MD_CompositeLocator/GeocodeServer?f=pjson
I want to use this in the tidygeocoder library
https://cran.r-project.org/web/packages/tidygeocoder/vignettes/tidygeocoder.html
But I want to use the maryland geocoder instead of the Google or Censu geocoders. How would I set up the script to do this? Ideally I could add a new method of geocoding which uses the Maryland geocoder.
There's a comprehensive list of what to do to add a new method to the package here. However, to start you could try using the get_api_query and query_api functions to execute a query. You'll then need to extract the relevant data from the response and put it into dataframe format (the job of the extract_results function). Good luck and feel free to file an issue or reach out if you have questions.

Here.com api, getMapPackageAtGeoCoordinates for multiple coordinates

getMapPackageAtGeoCoordinates: take only 1 value as parameter.
I've a long list of NMAGeoCoordinates and I'm looking for a way to get the "packageId" without doing multiple calls (or using a bounding box as parameter)
UPDATE
My iOS app has a list of routes (hundreds of them) and each route has multiple intermediate points.
For each route should be possible to download the map data offline.
I'm using this api:
https://developer.here.com/documentation/ios-premium/dev_guide/topics/maps-offline-maploader.html
I'm not using the other method based on NMAMapDataPrefetcher because I need to have control over packages installed.
So given a list of NMAGeoCoordinates I need to get a list of possible NMAMapPackage to download.
I can't use the start or destination coordinate because each route can include multiple countries.
I can't call getMapPackageAtGeoCoordinates multiple times to get a complete list of possible countries included in a route (it's to many calls, on the order of tens for each route)
So I'm wondering if there a better way to solve this problem, maybe using a bounding box to get all the NMAMapPackage included in a route.
I've also checked the REST api:
https://developer.here.com/documentation/routing/topics/resource-calculate-route.html
looks like there a way to calculate a route and get a summary of country traversed, usign the RouteAttributeType "summaryByCountry". The response include a field "country" using an ISO 3166-1-alpha-3 format, but there no way to convert this value to an NMAMapPackage id.
There is no other way except you describe to receive NMAMapPackage using geoCoordinates.
This is the only way to use bounding box to download area he needs without multiple invocations.
#interface NMAGeoBoundingBox : NSObject<NSCoding>
+ (nullable instancetype)geoBoundingBoxContainingGeoCoordinates:(nonnull NSArray<NMAGeoCoordinates *> *)coordinates
#interface NMAMapDataPrefetcher : NSObject
- (NSInteger)fetchMapDataForBoundingBox:(nonnull NMAGeoBoundingBox *)boundingBox
error:(NMAPrefetchRequestError *_Nullable)error
NS_SWIFT_NAME(fetchMapDataForBoundingBox(_:error:));

How to create a 3D view just like BimViews using Java?

I am new to the plugin development of BimClientServerLib.
I have to create a plugin/service where i just need the 3D view and get all the information, so that if i push some information like simulate Door_1 it should be highlighted in the 3D View.I have used the [BimServerClientLib] to check in the project and retrieve some information like get all levels or get all detectors with existing BimViews as 3D viewer and the BIMServerClientLib as a separate Java service.Also, if i use the BimViews which is in Java script how do i push information with the service in Java.
Have a look at BIMSurfer. Download the project into any server (like tomcat), then navigate to the index.html. They have two examples, local one without a BIMServer and another with a connection to BIMServer.
You can adjust their BIMServer example to load your project and for highlighting a specific element, you can the provided library methods (available on the BIMSurfer github main page).
bimSurfer.setSelection({ids: ["object3", "object2", "object4", "object6"], selected: true });
Goodluck.

Zip Code Boundaries Using Google Maps Api

I need to display google map with zip code boundaries like this
http://maps.huge.info/zip.htm
Perhaps I am overlooking it, but I've not been to find examples of this and documentation talking about this specifically at Google Maps API documentation. I've trying doing a view source on the above web page link, but it doesn't seem obvious to me how it works. There is also other stuff on the page which I don't know if it's part of what I need or not.
Some simple code examples would be very helpful! Thanks!
If anyone still looking for the solution here is how I managed to draw boundaries.
Download zip file from http://www2.census.gov/geo/tiger/TIGER2014/ZCTA5/tl_2014_us_zcta510.zip (its around 500mb)
Unzip it, u need the shp file from the extracted files
On windows u need to install QGIS, to get the ogr2ogr utility
Run the command to get geoJSON file from shp file:
ogr2ogr -f "GeoJSON" -lco COORDINATE_PRECISION=4 -simplify 0.00010 zipRegions.json tl_2014_us_zcta510.shp
You can play with simplify to remove extra points and compress your data
Create free account on cartodb
Upload zipRegions.json file there
Now using cartodb.js file you can draw zip code regions on google maps easily
Simply by code like this
var mapOptions = {
zoom: 12,
center: new google.maps.LatLng(42.1038846,-72.5868353),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map'), mapOptions);
cartodb.createLayer(map, {
user_name: 'your_user_name',
type: 'cartodb',
sublayers: [
{
sql: "SELECT * FROM cartodb1",
cartocss: '#cartodb1 {polygon-fill: #7bd490;polygon-opacity: 0.7;line-color: #6da57a;line-width: 0.5;line-opacity: 1;}'
}
]})
.addTo(map, 0) // add the layer to our map which already contains 1 sublayer
.done(function(layer) {
console.log('Fine');
})
.error(function(e) {
console.log(e);
});
Google Maps API will not provide you with this data. You need an external source. A Fusion Table could be of some help. You can check this one *.
You then need to create your own layers from the KML data that is in the table. There is documentation about it.
You can render the data directly from the Fusion Table or import it to your own database, which is often preferable for performance.
Hope this helps to get you started. Try to find your way and if you are stuck, then ask another question and show us your code as the first comment suggests.
* FusionTables was discontinued on 3 December 2019.
Working on the same thing and found boundaries-io way too expensive for our use case.
Check out https://www.maptechnica.com/
Much larger data set
Much more affordable
I parsed the 2016 census kml file (over 150MB) to over 32,000 individual kml files you can use as a kml layer for your maps.
I put a zip file here:
https://github.com/tomeralmog/zipcode-kml
Hope this helps
A Very Simply API exists for this query by zipcode,city,etc.. returns geoJson
http://www.boundaries-io.com
Image of the results in GooleMap:
I know this is a relatively old question and #tomer-almog has done some great work making KML files, but I stumbled on this free resource (no relation, just using the data) that has zip code data in verious geo formats (GeoJSON, KML, etc)
https://public.opendatasoft.com/explore/dataset/us-zip-code-latitude-and-longitude/table/
Might be usefull for someone....

Resources